<?php
// +----------------------------------------------------------------------
// | FastXCMS [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.fastxcms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\model;

use think\Db;
use think\Model;

class UserIntegralModel extends Model
{
    public function favorites()
    {
        $userId        = cmf_get_current_user_id();
        $userQuery     = Db::name("UserScoreLog");
        $favorites     = $userQuery->where(['user_id' => $userId])->order('id desc')->paginate(10);
        $data['page']  = $favorites->render();
        $data['lists'] = $favorites->items();
		foreach($data['lists'] as $key=>$val)
		{
			if($val['action'] == 'login')
			{
				$data['lists'][$key]['actionname'] = '用户登录';	
			}
			if($val['action'] == 'goods')
			{
				$data['lists'][$key]['actionname'] = '购买商品';	
			}
		}
        return $data;
    }

}